<template>
    <div class="about-container">
        <!-- HTML标签分类列表 -->
        <div class="category-section">
            <h2 class="section-title">HTML 标签分类</h2>
            <div class="category-grid">
                <div v-for="item in htmldatas.HTML" :key="item.id" @click="dianji(item.detail)" class="category-card"
                    :class="{ active: JSON.stringify(datas) === JSON.stringify(item.detail) }">
                    <span class="category-name">{{ item.C_N }}</span>
                    <!-- <span class="tag-count">{{ item.detail?.length || 0 }} 个标签</span> -->
                </div>
            </div>
        </div>

        <!-- 标签详情展示区域 -->
        <div v-if="datas" class="details-section">
            <h2 class="section-title">标签详情</h2>
            <div class="details-container">
                <div class="details-scroll">
                    <div v-for="(item, index) in datas" :key="index" class="detail-card">
                        <div class="tag-info">
                            <span class="tag-name">&lt;{{ item.tag }}&gt;</span>
                            <span class="tag-description">{{ item.description }}</span>
                            <span class="tag-function">{{ item.function }}</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref } from 'vue';
import htmldatas from '@/assets/JSON/html.json';


//数据

let datas = ref(null);

function dianji(data) {
    if (JSON.stringify(datas.value) === JSON.stringify(data)) {
        datas.value = null;
    } else {
        datas.value = data;
    }
}


</script>
<!-- 样式 -->
<style scoped>
.about-container {
    /* max-width: 1200px; */
    /* margin: 0 auto; */
    padding: 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.section-title {
    color: #2c3e50;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    border-bottom: 3px solid #3498db;
    padding-bottom: 10px;
}

/* 分类卡片网格布局 */
.category-section {
    margin-bottom: 40px;
}

.category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 30px;
    justify-content: flex-start;
}

.category-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    color: white;
    position: relative;
    overflow: hidden;
    flex: 0 0 auto;
    /* min-width: 160px;
    max-width: 200px; */
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.category-card:hover::before {
    left: 100%;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.category-card.active {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

.category-name {
    /* font-size: 18px;
    font-weight: 600; */
    margin: 0 0 8px 0;
    color: white;
}

.tag-count {
    font-size: 14px;
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 12px;
    display: inline-block;
}

/* 详情区域布局 */
.details-section {
    animation: fadeInUp 0.5s ease;
}

.details-container {
    width: 100%;
    overflow-x: auto;
    padding: 10px 0;
}

.details-scroll {
    display: flex;
    gap: 15px;
    min-width: max-content;
    padding-bottom: 10px;
}

.detail-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
    transform: translateY(20px);
    flex: 0 0 auto;
    /* min-width: 300px;
    max-width: 400px; */
    white-space: nowrap;
    border: 1px solid #e1e8ed;
    overflow: hidden;
}

.detail-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.tag-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
    color: white;
}

.tag-name {
    color: #ffd700;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    text-overflow: ellipsis;
    overflow: hidden;
}

.tag-description {
    color: #f0f8ff;
    font-size: 14px;
    line-height: 1.4;
    text-overflow: ellipsis;
    overflow: hidden;
}

.tag-function {
    color: #e6e6fa;
    font-size: 13px;
    font-style: italic;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* 动画效果 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .about-container {
        padding: 15px;
    }

    .category-grid {
        gap: 12px;
    }

    .category-card {
        min-width: 140px;
        max-width: 180px;
        padding: 12px 16px;
    }

    .details-container {
        padding: 8px 0;
    }

    .details-scroll {
        gap: 12px;
    }

    .detail-card {
        min-width: 250px;
        max-width: 300px;
        padding: 12px;
    }

    .tag-info {
        gap: 6px;
    }

    .tag-name {
        font-size: 14px;
    }

    .tag-description {
        font-size: 13px;
    }

    .tag-function {
        font-size: 12px;
    }

    .section-title {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .category-grid {
        gap: 10px;
        justify-content: center;
    }

    .category-card {
        min-width: 120px;
        max-width: 150px;
        padding: 10px 12px;
    }

    .category-name {
        font-size: 13px;
    }

    .tag-count {
        font-size: 11px;
    }

    .details-container {
        padding: 5px 0;
    }

    .details-scroll {
        gap: 10px;
    }

    .detail-card {
        min-width: 200px;
        max-width: 250px;
        padding: 10px;
    }

    .tag-info {
        gap: 5px;
    }

    .tag-name {
        font-size: 13px;
    }

    .tag-description {
        font-size: 12px;
    }

    .tag-function {
        font-size: 11px;
    }
}
</style>